package com.scut.online_black_market.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.scut.online_black_market.dto.*;
import com.scut.online_black_market.entity.ProductSellout;
import com.scut.online_black_market.exception.AskForProductException;
import com.scut.online_black_market.exception.BalanceException;
import com.scut.online_black_market.exception.SellProductException;
import com.scut.online_black_market.exception.UniversalException;


/**
 * create by yellowBroke on 2020年10月12日 17点06分
 * ProductTradeService ： 商品交易服务
 */

public interface ProductTradeService {

    /**
     * 上架商品
     * @param productInfo
     * @throws SellProductException
     */
    void sellProduct(ProductInfo productInfo) throws SellProductException;

    /**
     * 分页查询商品信息
     * @param pageNo
     * @param pageSize
     * @return
     */
    IPage<ProductSellout> queryProductByPage(int pageNo, int pageSize, int queryType);

    /**
     *
     * @param productId
     * @return
     */
    ProductResponse queryById(long productId) throws UniversalException;

    /**
     * 发布求购商品
     * @param shoppingGuideInfo
     * @throws AskForProductException
     */
    void askForProduct(ShoppingGuideInfo shoppingGuideInfo)throws AskForProductException;

    /**
     * created by xxl at 2020/11/21-9:19
     * @param productId
     * @return
     */
    SuccessResponse sell(long productId) throws UniversalException;

    /**
     * created by xxl at 2020/11/21-10:17
     * @param productId
     * @return
     */
    SuccessResponse shoppingGuideTradeFinished(long productId) throws UniversalException;

    /**
     * @param productId
     * @param buyerId
     * @param sellmanId
     * @return
     */
    SuccessResponse purchase(long productId,String buyerId,String sellmanId)
            throws UniversalException, BalanceException;

    /**
     *
     * @param productId
     * @return
     */
    SuccessResponse tradeFinished(long productId) throws UniversalException;


    /**
     * 分页查询求购信息
     * @param pageNo
     * @param pageSize
     * @param typeId
     * @return
     */
    IPage<ShoppingGuideResponse> queryShoppingGuideByPage(short pageNo,short pageSize,short typeId);


}
